#{extends 'main.html' /}
#{set title:'CoolSoft - Edit Roles' /}
*{this is the page for the changing of role}*
	<script type="text/javascript" src="/public/javascripts/jquery.simpleMultiSelect.js"></script> 

	<script type="text/javascript"> 
      $(document).ready(function(){
        $('select#object_actions').simpleMultiSelect();
 
        $('a#none').click(function(){
            $('select#object_actions').smsNone();
        });
        $('a#all').click(function(){
            $('select#object_actions').smsAll();
        });
	});
	
  </script> 
        <link rel="stylesheet" type="text/css" media="screen" href="/public/stylesheets/crud.css" /> 
<body id="crud">
	<div id="crudContent"> 
		<h2>Edit Project Role</h2>
		<input type="hidden" name="roleId" value="${roleId}" />
		<div class="objectForm"> 
			<div class="crudField"> 
				#{form @Projects.inheritEditRole(title,roleId,projectId)}		
				<input type="hidden" name="projectId" value="${projectId}" />
					<label> 
							Choose Role to inherit from:
					</label>
					<select name="inheritRole" id="inheritRole">
						#{list items:rList, as:'role'}
							<option value="${role.id}" ${inheritRole==role.id ?' selected="true"':'selected="false"'}>${role.title}</option>
						#{/list}
					</select>
					<script type="text/javascript">
	           			 document.getElementById('inheritRole').value = '${r.id}'
	     			</script>
					<input type="submit" name="Inherit" value="Inherit" />
				#{/form}
				<br>
			</div>
			#{form @Projects.editRoleInProject(title,roleId,object_actions,projectId)}
				<div class="crudField"> 
						<label for="object_title"> 
							Title: <font color="red">*</font>
						</label> 
						<input class="validate[required]" type="text" name="title" id="title" value="${title}"  ${isSystemRole ? 'disabled="true"' : ''} size="50"/>
						<input type="hidden" name="title" value="${title}" />
						<span class="crudHelp"> 
							Required.
						</span>
				</div>
				<br>
				<div class="crudField"> 	
					<label for="object_actions"> 
						Allowed Actions: <font color="red">*</font>
					</label>
					<div>
						<select class="validate[required]" id="object_actions" name="action" multiple="yes">
							#{list items:aList, as:'action'}
								#{list items:aSelList, as:'actionSel'}
									#{if action.id==actionSel.id}
										<option value="${action.id}" selected="true">${action.name}</option>
										%{flag = "true";}%
									#{/if}
								#{/list}
								#{if flag != "true"}
								<option value="${action.id}">${action.name}</option>
								#{/if}
								%{flag = "false";}%
							#{/list}
						</select>
					</div>
					<span class="crudHelp">
	    				At Least one Action is Required.
				   	</span> 
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript: click()" id="none">None</a><b> | </b><a href="javascript: click()" id="all">All</a>
				</div>
				<br>
				<p class="crudButtons"> 
					<input type="submit" value="Edit"  />
				</p>
			#{/form}
			<p class="crudButtons" >
				#{form @Projects.getAllRoles(projectId)}
					<div align="center">
						<input type="submit" value="Back to Roles within this Project" /> 
					</div>
				#{/form}
			</p>
		</div>
	</div>	
</body>